import request from '@/utils/request'

// 查询角色分页数据
export const GetSysRolePage = (pageNum, pageSize, keyword) => {
  return request({
    url: `/admin/system/role/page/${pageNum}/${pageSize}`,
    method: 'get',
    //params/header/data 设置的都是json对象
    params: { keyword },
  })
}
//根据id删除角色
export const DeleteRoleById = id => {
  return request({
    url: `/admin/system/role/deleteById/${id}`,
    method: 'DELETE',
  })
}
//根据id查询角色
export const GetRoleById = id => {
  return request({
    url: `/admin/system/role/getById/${id}`,
    method: 'GET',
  })
}
//更新角色
export const UpdateRoleById = role => {
  return request({
    url: `/admin/system/role/updateById`,
    method: 'PUT',
    data: role,
  })
}
//新增角色
export const SaveRole = role => {
  return request({
    url: `/admin/system/role/save`,
    method: 'POST',
    data: role,
  })
}
export const GetRolesAndIsChecked = userId => {
  return request({
    url: `/admin/system/role/findRolesAndIsChecked/${userId}`,
    method: 'GET',
  })
}
export const AssignRoles2User = (userId, roleIds) => {
  return request({
    url: `/admin/system/userRole/assignRoles2User/${userId}`,
    method: 'PUT',
    data: roleIds,
  })
}
export const GetMenusById = roleId => {
  return request({
    url: `/admin/system/roleMenu/findMenusByRoleId/${roleId}`,
    method: 'GET',
  })
}
export const AssignMenus2Role = (roleId, menuIds) => {
  return request({
    url: `/admin/system/roleMenu/assignMenus2Role/${roleId}`,
    method: 'PUT',
    data: menuIds,
  })
}
